<template>
	<view class="container">
		<!-- 标题栏和状态栏占位符 -->
		<view class="titleNview-placing"></view>
		
		<scroll-view class="list" scroll-y="true" lower-threshold="20" @scrolltolower="add">
				<view class="goodsTitle">{{day}}本店新品上线</view>
				
		
			<view class="guess-section ">
				<view class="guess-item" v-for="l in list" :key="l.id" @click="toDetail(l.goods.id)">
					<view class="image-wrapper">
						<image :src="l.goods.fullDefaultImageUrl" mode="aspectFill"></image>
					</view>
					<view class="text">
						<text class="title clamp">{{l.goods.cName}}</text>
						<text class="price">
							<text class="unit">￥</text>{{l.goods.fSalePrice}} 
						<text class="pay">已付款{{l.goods.iSales}}人</text>
							<image class="collect" src="/static/img/2/2-13.png" mode="aspectFill"></image>
						</text>
					</view>
				
				</view>
				
				
				
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page:1,
				list:[],
				day:''
			};
		},
		props:["shop_id"],
		mounted() {

			this.getData()

		},

		methods: {
			getData(){
				
				this.$Request.post4(
					this.$api.httpApi.home.shopNewGoods, {
						"shop_id": this.shop_id,
						page:this.page,
						limit:20
					}
				).then(res => {
					if (res.code == 1) {
						this.list = this.list.concat(res.data.data)
						this.day = res.data.day
						this.page++
						this.list.forEach(item=>{
							this.getGoods(item)
						})
						
						
						if(res.data.data == 0){
							uni.showToast({
								title:"没有更多了！",
								icon:"none"
							})
						}
						
					}
				})
			},
			getGoods(item){
				this.$Request.get(this.$api.httpApi.goods.iteminfo + '&id=' + item.goods_id + '&token=' + this.$SysCache.get('token')).then(
					res => {
						if (res.code == 200) {
							this.$set(item,'goods',res.data)
						}
					})
			},
			toDetail(id){
				uni.navigateTo({
					url: `/pages/detail/index?id=${id}&iShopId=${this.shop_id}`
				})
			},
			add(){
				this.getData()
			}
		}

	}
</script>

<style lang="less" scoped>
	.container {
		height: 100%;
		background-color: #EBEBEB;
		.tab{
			margin-top: 50upx;
		}
		.titleNview-placing {
			height: var(--status-bar-height);
			padding-top: 420upx;
			box-sizing: content-box;
		}

		.list {
			background-color: #ebebeb;
			width: 100%;
			position: relative;
			z-index: 10;
			padding-top: 20rpx;
			height: 100%;
			.goodsTitle{
				text-align: center;
				padding: 10upx 0;
			}
			.guess-section {
				display:flex;
				flex-wrap:wrap;
				padding: 0 30upx;
				

				.guess-item {
					display:flex;
					flex-direction: column;
					width: 48%;
					padding-bottom: 29upx;
					background: #fff;
					margin-bottom: 21upx;
							
					&:nth-child(2n+1){
						margin-right: 21upx;
					}

				}
				.image-wrapper {
					width: 100%;
					height: 330upx;
					border-radius: 3px;
					overflow: hidden;
					background: #fff;
					image{
						width: 100%;
						height: 100%;
						opacity: 1;
					}
				}

				.title{
					font-size:23upx;
					font-family:Microsoft YaHei;
					font-weight:400;
					color:rgba(68,68,68,1);
					line-height: 35upx;
					padding-left: 30upx;
					padding-right: 30upx;
				}

				

				.price{
					font-size:26upx;
					    display: block;
					font-family:Adobe Heiti Std;
					font-weight:normal;
					color:rgba(240,64,111,1);
					padding-left: 30upx;
					position: relative;
					.pay{
						font-size:17upx;
						font-family:Microsoft YaHei;
						font-weight:400;
						color:rgba(153,153,153,1);
						margin-left: 6upx;
					}
					.collect{
						position: absolute;
						right: 29upx;
						bottom: 10upx;
						width:30upx;
						height:28upx;
						z-index: 1;
					}
				
				}


			}

			
		}

	
	}

	.con {
		height: calc(100% - 153rpx);
		background-color: #EBEBEB;

	}
</style>
